/*     */ package com.newcrm.manager;
/*     */ 
/*     */ import com.newcrm.db.CompanyExtManager;
/*     */ import com.newcrm.util.UCPAASUtil;
/*     */ import com.newcrm.util.VOIPUtil;
/*     */ import java.io.File;
/*     */ import java.util.Date;
/*     */ 
/*     */ public class SyncVOIPCallRecordsManager
/*     */ {
/*  19 */   private static SyncVOIPCallRecordsManager manager = null;
/*     */ 
/*  21 */   private boolean isRunning = false;
/*     */ 
/*     */   private SyncVOIPCallRecordsManager() {
/*  24 */     this.isRunning = false;
/*     */   }
/*     */ 
/*     */   public static SyncVOIPCallRecordsManager getInstance() {
/*  28 */     if (manager == null) {
/*  29 */       manager = new SyncVOIPCallRecordsManager();
/*     */     }
/*  31 */     return manager;
/*     */   }
/*     */ 
/*     */   public boolean getStatus()
/*     */   {
/*  40 */     return this.isRunning;
/*     */   }
/*     */ 
/*     */   public void sync(int companyId, String filePath, Date startDate, Date endDate)
/*     */   {
/*  48 */     if (this.isRunning) {
/*  49 */       return;
/*     */     }
/*     */ 
/*  52 */     File path = new File(filePath);
/*  53 */     if (!path.exists()) {
/*  54 */       return;
/*     */     }
/*     */ 
/*  57 */     this.isRunning = true;
/*     */ 
/*  60 */     CompanyExtManager manager = new CompanyExtManager();
/*  61 */     String serverIP = manager.getFieldValue(companyId, 
/*  62 */       6);
/*  63 */     if ((serverIP == null) || (serverIP.trim().length() == 0)) {
/*  64 */       this.isRunning = false;
/*  65 */       return;
/*     */     }
/*     */ 
/*  68 */     boolean isUCPAAS = false;
/*  69 */     if (serverIP.contains("ucpaas.qikebao.com")) {
/*  70 */       isUCPAAS = true;
/*     */     }
/*     */ 
/*  73 */     String userName = manager.getFieldValue(companyId, 
/*  74 */       4);
/*  75 */     if ((userName == null) || (userName.trim().length() == 0)) {
/*  76 */       this.isRunning = false;
/*  77 */       return;
/*     */     }
/*  79 */     String userPwd = manager.getFieldValue(companyId, 
/*  80 */       5);
/*  81 */     if ((userPwd == null) || (userPwd.trim().length() == 0)) {
/*  82 */       this.isRunning = false;
/*  83 */       return;
/*     */     }
/*     */ 
/*  87 */     Date syncEndDate = endDate;
/*  88 */     if (syncEndDate == null) {
/*  89 */       syncEndDate = new Date();
/*     */     }
/*  91 */     if (isUCPAAS) {
/*  92 */       UCPAASUtil.loadCallLog(userName, "", startDate, syncEndDate, "", 
/*  93 */         companyId, 1, false);
/*     */     }
/*     */ 
/*  97 */     long startTime = System.currentTimeMillis();
/*     */ 
/* 100 */     int num = VOIPUtil.downloadFile(filePath);
/* 101 */     while (num > 0) {
/* 102 */       long endTime = System.currentTimeMillis();
/*     */ 
/* 104 */       if (endTime - startTime > 7200000L)
/*     */       {
/*     */         break;
/*     */       }
/* 108 */       num = VOIPUtil.downloadFile(filePath);
/*     */     }
/*     */ 
/* 111 */     this.isRunning = false;
/*     */   }
/*     */ 
/*     */   public void updateRunningStatus(boolean flag)
/*     */   {
/* 120 */     this.isRunning = flag;
/*     */   }
/*     */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.manager.SyncVOIPCallRecordsManager
 * JD-Core Version:    0.6.1
 */